/*
 * File Name: WindowHelper.java
 * Created on: November 11 2007, 11:35 AM
 */
package co.edu.uniandes.intercon.client.gui.util;

import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Window;

/**
 * Window utility class
 * 
 * @author Fabian Gutierrez [fagossa@gmail.com]
 */
public class WindowHelper {

    /**
     * Center the window specified in the middle of the screen
     * 
     * @param   window  Window used to set the cursor
     */
    public static void centerWindow(Window window) {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = toolkit.getScreenSize();
        int x = (screenSize.width - window.getWidth()) / 2;
        int y = (screenSize.height - window.getHeight()) / 2;
        window.setLocation(x, y);
    }

    /**
     * Sets the waiting cursor to the window specified
     * @param   window  Window used to set the cursor
     */
    public static void setDefaultCursor(Container window) {
        window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }

    /**
     * Sets the waiting cursor to the window specified
     * @param   window  Window used to set the cursor
     */
    public static void setWaitingCursor(Container window) {
        window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    }
}
